//
//  MyCollectionTableViewCell.m
//  心水宝典
//
//  Created by zr on 2018/8/29.
//  Copyright © 2018年 zr. All rights reserved.
//

#import "MyCollectionTableViewCell.h"

@interface MyCollectionTableViewCell ()


@property (nonatomic, weak)UIImageView * leftImageView;
@property (nonatomic, weak)UILabel * titleLabel;
@property (nonatomic, weak)UIButton * cancelButton;
@property (nonatomic, weak)UIView * lineView;

@end

@implementation MyCollectionTableViewCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    if ([super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self setupUI];
    }
    
    return self;
}


- (void)setupUI{
    
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    self.backgroundColor = [UIColor whiteColor];
    
    UILabel * titleLabel = [UILabel new];
    
    titleLabel.textColor = [UIColor blackColor];
    titleLabel.font = [UIFont systemFontOfSize:15 * SCREENH6];
    titleLabel.text = @"Setting the background color";
    
    self.titleLabel = titleLabel;
    
    [self.contentView addSubview:self.titleLabel];
    
    
    UIImageView * leftImageView = [UIImageView new];
    
    leftImageView.backgroundColor = [UIColor lightGrayColor];
    self.leftImageView = leftImageView;
    
    [self.contentView addSubview:self.leftImageView];
    
    
    UIButton * cancelButton = [UIButton new];
    
    [cancelButton setTitle:@"取消收藏" forState:UIControlStateNormal];
    [cancelButton setTitleColor:ColorWithRGB(0xB9B9B9) forState:UIControlStateNormal];
    [cancelButton addTarget:self action:@selector(clickCancelButton) forControlEvents:UIControlEventTouchUpInside];
    cancelButton.titleLabel.font = [UIFont systemFontOfSize:13 * SCREENH6];
    
    self.cancelButton = cancelButton;
    
    [self.contentView addSubview:self.cancelButton];
    
    UIView * lineView = [UIView new];
    
    lineView.backgroundColor = ColorWithRGB(0XE4E4E4);
    
    self.lineView = lineView;
    
    [self.contentView addSubview:self.lineView];
}


-(void)layoutSubviews{
    
    [self.leftImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.contentView);
        make.leading.mas_equalTo(self.contentView).offset(15 * SCREENH6);
        make.width.height.mas_equalTo(85 * SCREENH6);
    }];
    
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.leftImageView);
        make.leading.mas_equalTo(self.leftImageView.mas_trailing).offset(10 * SCREENH6);
        make.trailing.mas_equalTo(self.contentView).offset(-10 * SCREENH6);
    }];
    
    [self.cancelButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.trailing.mas_equalTo(self.contentView).offset(-15 * SCREENH6);
        make.bottom.mas_equalTo(self.leftImageView);
    }];
    
    [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.trailing.bottom.mas_equalTo(self.contentView);
        make.height.mas_equalTo(1 * SCREENH6);
    }];
}


- (void)clickCancelButton{
    
    
}


- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
